#include "..\main\common.h"



#define  BufferSize (countof(Tx_Buffer)-1)
vu32 FLASH_ID = 0;
u8 Tx_Buffer[512];
u8 Rx_Buffer[BufferSize];



int main(void)
{
	Sys_Init();

	Delay(0xFFFFF);
	FLASH_ID = SPI_FLASH_ReadID();
	UART_Put_Msg("FALSH_ID = ", FLASH_ID, 4);
	if (FLASH_ID == AT45DB161D_FLASH_ID)
	{
		LED1_ON();
	}
	else
	{
		LED2_ON();
	}
	SPI_FLASH_PageErase(FLASH_SectorToErase);
	MemSet(Tx_Buffer, 0x55, 512);
	MemSet(Rx_Buffer, 0x00, 512);
	
	SPI_FLASH_BufferWrite(Tx_Buffer, FLASH_WriteAddress, BufferSize);
	SPI_FLASH_BufferRead(Rx_Buffer, FLASH_ReadAddress, BufferSize);
	UART_Put_Mem(Rx_Buffer, 512);
	SPI_FLASH_PageErase(FLASH_SectorToErase);
	SPI_FLASH_BufferRead(Rx_Buffer, FLASH_ReadAddress, BufferSize);
	UART_Put_Mem(Rx_Buffer, 512);
#if 1	
	while(1)
	{
		LED3_ON();
		Delay(0xAFFFF);
		LED3_OFF();
		Delay(0xAFFFF);
	}
	#endif
}



